from rest_framework.authentication import BaseAuthentication
from rest_framework import exceptions


class MyAuthorization(BaseAuthentication):
    def authenticate(self, request):
        token = request.META.get('HTTP_TOKEN')
        if token:
            return None,None
        else:
            raise exceptions.AuthenticationFailed('token认证失败')